package BiShi.tengxun;

import java.util.LinkedList;
import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            double[] ans = new double[n];
            int ind = 0;
            while(n-- > 0){
                int M = sc.nextInt();
                int[][] a = new int[M][2];
                int[][] b = new int[M][2];
                for (int i = 0; i < M; i++){
                    a[i][0] = sc.nextInt();
                    a[i][1] = sc.nextInt();
                }
                for (int i = 0; i < M; i++){
                    b[i][0] = sc.nextInt();
                    b[i][1] = sc.nextInt();
                }
                double res = Integer.MAX_VALUE;
                for (int i = 0; i < M; i++){
                    for (int j = 0; j < M; j++){
                       res = Math.min(Math.sqrt(Math.pow(((double)a[i][0]-b[j][0]),2) + Math.pow(((double)a[i][1]-b[j][1]),2)),res);
                    }
                }
                ans[ind++] = res;
            }
            for (int i = 0; i < ans.length; i++){
                System.out.printf("%.3f", ans[i]);
                System.out.println();
            }
        }
    }
}



